package com.horoscope.astrology.zodiac.signs.free.fragment.quiz

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.horoscope.astrology.zodiac.signs.free.R
import com.horoscope.astrology.zodiac.signs.free.adapter.quize.QuizImageAdapter
import com.horoscope.astrology.zodiac.signs.free.bean.QuestionBean
import com.horoscope.astrology.zodiac.signs.free.bean.QuizBean
import com.horoscope.astrology.zodiac.signs.free.fragment.BaseFragment
import com.horoscope.astrology.zodiac.signs.free.utils.CommonDecoration3

class QuizImageFragment : BaseFragment() {

    private lateinit var mRecyclerView: RecyclerView
    private lateinit var mAdapter: QuizImageAdapter
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.fragment_quiz_image, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        mRecyclerView = view.findViewById(R.id.recycler_view_question_image)
        mRecyclerView.layoutManager = LinearLayoutManager(activity)
        mAdapter = QuizImageAdapter(activity)
        val bean = arguments?.getSerializable("bean") as QuestionBean
        mAdapter.setBean(bean)
        mRecyclerView.adapter = mAdapter
        mRecyclerView.addItemDecoration(CommonDecoration3(13f, 20f))
    }

    companion object {
        fun getFragment(position: Int, bean: QuizBean): QuizImageFragment {
            val fragment = QuizImageFragment()
            val bundle = Bundle()
            bundle.putSerializable("bean", bean.questions[position])
            fragment.arguments = bundle
            return fragment
        }
    }
}